<?php

#<editor-fold defaultstate="collapsed" desc="CCore::Using">
CCore::Using('logger.inc.abstract');
#</editor-fold>

class CCoreLoggerInline extends ACoreLogger
{
	#<editor-fold defaultstate="collapsed" desc="private">
	/**
	 * @var	string
	 */
	private $_sNewLine;

	/**
	 * @var	bool
	 */
	private $_bHtmlDecodeSpecialChars;
	#</editor-fold>

	/**
	 * @param	string	$sNewLine = "\n"
	 * @param	bool	$bHtmlDecodeSpecialChars = false
	 * @return	CCoreLoggerInline
	 */
	public function __construct($sNewLine = "\n", $bHtmlDecodeSpecialChars = false)
	{
		CCore::CheckTypes(array('$sNewLine', '$bHtmlDecodeSpecialChars'));
		
		$this->_sNewLine = $sNewLine;
		$this->_bHtmlDecodeSpecialChars = $bHtmlDecodeSpecialChars;
	}
	
	/**
	 * @param	string	$sErrorDesc
	 * @return	bool
	 */
	protected function writeImplementation($sErrorDesc)
	{
		CCore::CheckTypes(array('$sErrorDesc'));

		echo ($this->_bHtmlDecodeSpecialChars)
			? htmlspecialchars($sErrorDesc).$this->_sNewLine : $sErrorDesc.$this->_sNewLine;
		
		return true;
	}

	/**
	 * @param	string	$sTimePrefix
	 * @param	string	$sErrorDesc
	 * @return	string
	 */
	protected function logLineImplementation($sTimePrefix, $sErrorDesc)
	{
		CCore::CheckTypes(array('$sTimePrefix', '$sErrorDesc'));
		
		return '['.$sTimePrefix.'] '.$sErrorDesc;
	}

	/**
	 * @return	bool
	 */
	protected function clearImplementation()
	{
		return true;
	}
}
